ComponentOne Zip for UWP
Zip for UWP Task-Based Help / Loading a Zip File from the Web
In This Topic
    Loading a Zip File from the Web
    In This Topic

    You can reduce application size by downloading zip files asynchronously from the Web. Use the following code to open a zip file from the Web into a C1ZipFile object.

    C#
    Copy Code
    using C1.C1Zip;
    using System.Net.Http;
    using Windows.UI.Popups;
    
    private async void LoadZipFile()
    {
        // load file from the Web
        HttpClient client = new HttpClient();
        C1ZipFile zip = new C1ZipFile();
        try
        {
            // Download zip into byte array.
            var byteArray = await client.GetByteArrayAsync(new Uri("htt://yourfile.zip", UriKind.Absolute));
    
            // Write byte array to stream and open
            MemoryStream ms = new MemoryStream();
            ms.Write(byteArray, 0, byteArray.Length);
            zip.Open(ms);
    
            // Load entries into FlexGrid
            _flex.ItemsSource = zip.Entries;
        }
        catch (Exception ex)
        {
            var dialog = new MessageDialog(ex.Message);
            dialog.ShowAsync();
        }
    }
    
    See Also